$(function(){
	
	//查询最新消息类别列表
	newsTypeList();
});

/**
 * @title   查询最新消息类别列表
 * @return  type:  消息类别0：交易物流信息，1：通知消息，2：我的问答 3：商品咨询
 * @return  typeTitle：消息类别类别描述
 * @return  hotNew: 最新消息动态
 * @return  latestTime: 消息最新时间
 * @date    2017-06-15
 * @author  LeiJia
 */
function newsTypeList(){
	var mId = member.mId;
	var url = rootPath + "/member/newsTypeList";
	var result = CommnUtil.ajax(url,{"mId":mId },"json");
	if(result.resultSuccess){
		var data = result.data;
		if(CommnUtil.notNull(data)){
			$.each(data,function(i,news){
				var type = news.type;
				newsType(type,news);
			});
		}
	}else{
		alert("查询消息中心消息类别错误!");
	}
}

function newsType(type,news){
	var accessUrl = '';
	var li ='';
	var hotNew = news.hotNew;
	var time = news.latestTime;
	if("0" == type){//交易物流信息
		accessUrl = rootPath + "/member/newsCenter";
		li ='<li>'
			       + '<a href="'+accessUrl+'" >'
			       +    '<img src="'+rootPath+'/image/wll.png" alt="" />'
			       + 	'<p>'+news.typeTitle+'</p>'
			       + 	'<time>'+time+'</time>'
			       + 	'<span class="wordO">'+hotNew.substr(0,19)+'...'+'</span>'
			       + '</a>'
			  +'</li>';
		
	}else if("1" == type){//通知消息
		accessUrl = rootPath + "/member/systemNotification";
		li ='<li>'
		       + '<a href="'+accessUrl+'" >'
		       +    '<img src="'+rootPath+'/image/tz.png" alt="" />'
		       + 	'<p>'+news.typeTitle+'</p>'
		       + 	'<time>'+time+'</time>'
		       + 	'<span>'+hotNew.substr(0,19)+'...'+'</span>'
		       + '</a>'
		  +'</li>';
		
	}else if("2" == type){//我的问答
		accessUrl = rootPath + "/member/myQuestion";
		li ='<li>'
		       + '<a href="'+accessUrl+'" >'
		       +    '<img src="'+rootPath+'/image/wd.png" alt="" />'
		       + 	'<p>'+news.typeTitle+'</p>'
		       + 	'<time>'+time+'</time>'
		       + 	'<span>'+hotNew.substr(0,19)+'...'+'</span>'
		       + '</a>'
		  +'</li>';
	}else if("3" == type){//商品咨询
		li ='<li>'
		       + '<a href="#">'
		       +    '<img src="'+rootPath+'/image/lt.png" alt="" />'
		       + 	'<p>'+news.typeTitle+'</p>'
		       + 	'<time>'+time+'</time>'
		       + 	'<span>'+hotNew.substr(0,19)+'...'+'</span>'
		       + '</a>'
		  +'</li>';		
	}
	$(".news").append(li);
}